﻿using System.Web;
using System.Web.Mvc;

namespace CodeContrib.Web.Mvc.Html
{
	public static class FaviconExtensions
	{
		public static MvcHtmlString Favicon(this HtmlHelper htmlHelper)
		{
			return Favicon(htmlHelper, VirtualPathUtility.ToAbsolute("~/favicon.ico"));
		}

		public static MvcHtmlString Favicon(this HtmlHelper htmlHelper, string url)
		{
			var favicon = new TagBuilder("link");
			favicon.Attributes.Merge("href", url, true);
			favicon.Attributes.Merge("rel", "shortcut icon", true);

			return MvcHtmlString.Create(favicon.ToString(TagRenderMode.SelfClosing));
		}
	}
}